package JavaSE.Class11.InnerClasses;

//实例内部类
class OutClass2{
    public int data1=1;
    private int data2=2;
    public static int data3=3;

    class InnerClass2{
        public int data1=1000;
        private int data4=4;
        public static int data5=5;
        public int data6=6;

        OutClass2 outClass2=new OutClass2();
        public void test2(){
            //对于实例内部类有两个this
            System.out.println(data1);
            System.out.println(outClass2.data1);
            System.out.println(OutClass2.this.data1);
        }

        public void test(){
            System.out.println(data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("test方法被执行了...");
        }
    }
}

//静态内部类
public class OutClass {
    public int data1=1;
    private int data2=2;
    public static int data3=3;

    static class InnerClass1{
        private int data4=4;
        public static int data5=5;
        public int data6=6;

        public void display(){
            OutClass outClass=new OutClass();

            //静态内部类不能直接访问非静态内部类的成员变量
            System.out.println(data4);
            System.out.println(outClass.data1);

            //静态内部类可以访问外部类的静态成员变量
            System.out.println(data3);

            System.out.println("===========");

            System.out.println(outClass.data1);
            System.out.println(outClass.data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);

            System.out.println("display 方法被执行了...");
        }
    }
}
